package ThreadPool;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 创建一个定时器
 * 创建一个定时任务
 */
public class demo3 {
    public static void main(String[] args) throws InterruptedException {
        Timer timer = new Timer();
        timer.schedule(new TimerTask(){
            @Override
            public void run() {
                System.out.println("hello 1000ms");
            }
        },1000);

        timer.schedule(new TimerTask(){
            @Override
            public void run() {
                System.out.println("hello 2000ms");
            }
        },2000);

        timer.schedule(new TimerTask(){
            @Override
            public void run() {
                System.out.println("hello 3000ms");
            }
        },3000);

        Thread.sleep(3000);
        timer.cancel();
    }

}
